<?php

class Admin_Form_UserForm extends Zend_Form
{

    public function init()
    {
        $this->setMethod('post');
        $this->setAttrib('class', 'validate-form');
        
        $this->addElement('text','txtUser',array(
        					'label'		=>	'Tên đăng nhập (*)',
        					'required'	=>	true,
        					'class'		=>	'required'
        				));
       	$this->addElement('password','txtPass',array(
        					'label'		=>	'Mật khẩu (*)',
        					'required'	=>	true,
        					'class'		=>	'required',
       						'maxlength'	=> 	8,
       						'minlength'	=>	3
        				));
      	$this->addElement('text','txtHoDem',array(
        					'label'		=>	'Họ đệm (*)',
        					'required'	=>	true,
        					'class'		=>	'required'
        				));
        $this->addElement('text','txtTen',array(
        					'label'		=>	'Tên (*)',
        					'required'	=>	true,
        					'class'		=>	'required'
        				));
		$this->addElement('text','txtEmail',array(
        					'label'		=>	'Email',
							'class'		=>	'email'
        				));
        $this->addElement('text','txtNgaySinh',array(
        					'label'		=>	'Ngày sinh (*)',
        					'required'	=>	true,
        					'class'		=>	'required',
        					'id'		=>	'birthday'	
        				));
        $this->addElement('select','cbbRole',array(
        					'label'			=>	'Quyền (*)',
        					'required'		=>	true,
        					'multiOptions'	=> 	array(
        										'sinhvien'	=>	'Sinh viên',
        										'giaovien'	=>	'Giảng Viên'
        									)
        				));

        $this->addElement('select','cbbLop',array(
	        				'label'			=>	'Lớp',
	        				'multiOptions'	=>	$this->getLop()		
			        	));
    }

    /**
     * 
     * Set action cho form
     * @param unknown_type $actionName: ten cua action
     */
    function addAction($actionName){
    	$this->setAction(Zend_Controller_Front::getInstance()->getBaseUrl()."/admin/user/".$actionName);
    }
    
    function addAction_Url($module="front", $controller, $actionName){
    	$this->setAction(Zend_Controller_Front::getInstance()->getBaseUrl()."/".$module."/".$controller."/".$actionName);
    }
    /**
     * 
     * Add nut submit 
     */
    function addSubmitButton($name, $label){
    	$this->addElement('submit',$name,array(
    						'label'		=>	$label,
    						'decorators'=>	array('ViewHelper',array('HtmlTag',array(
    																			'tag' => 'dd' //giu nguyen the dd ko them bat cu the j
    																		)
    														
    															)
    							
    										),
    						'class'		=>	'input-hover uSubmit'	
    					));
    	
    }
    
    function addHiddenId($name,$value){
    	$this->addElement('hidden',$name,array(
			    				'value'	=> $value	
    						));
    }

	private function getLop(){
    	$lop 	= new Admin_Model_Lops();
    	$lops 	= $lop->getAllLop();
    	$data 	= array();
    	foreach ($lops as $value) {
    		$data[$value['id']] = $value['tenLop'];
    	}
    	return $data;
    }
}

